package arcane.object.gui.specific;

import java.util.HashSet;
import java.util.Set;

import arcane.object.gui.filter.KeyboardFilter;

public class ArcaneKeyboardFilter implements KeyboardFilter {
	Set<Character> bannedChars;

	public ArcaneKeyboardFilter() {
		this("");
	}
	public ArcaneKeyboardFilter(String bannedChars){
		this(bannedChars.toCharArray());
	}
	public ArcaneKeyboardFilter(char... c) {
		bannedChars = new HashSet<Character>();
		if (c != null)
			for (int i = 0; i < c.length; i++) {
				bannedChars.add(c[i]);
			}
	}

	public Set<Character> getBannedChars() {
		return bannedChars;
	}

	public void banChar(char c) {
		bannedChars.add(c);
	}

	public void removeBanChar(char c) {
		bannedChars.remove(c);
	}

	public boolean allowChar(char c) {
		return !bannedChars.contains(c);
	}

	public boolean allowString(String s) {
		char[] c = s.toCharArray();
		for (int i = 0; i < c.length; i++) {
			if (bannedChars.contains(c[i])) {
				return false;
			}
		}
		return true;
	}
}
